#include "stdafx.h"
#include "pixelStorage.h"
#include "gpu.h"

GPU::GPU(PixelStorage &pS) {
	pS.imagePath = "tests/Objekte5.tif";
	pS.grayImage = imread(pS.imagePath, 0);

	pS.gpuGrayImage.upload(pS.grayImage);
	pS.gpuBinMatrix.upload(pS.binMatrix);
}

GPU::~GPU() {
}

void GPU::raster(PixelStorage &pS) {
	cv::threshold(pS.grayImage, pS.binMatrix, 128, 1, THRESH_BINARY);
}

void GPU::calcTrueContours(PixelStorage &pS) {
	Mat circles;

	int maxCircles = 40, minRadius = 1, maxRadius = 2, voteThresh = 1,
			cannyThresh = 255;
	float minDist = 1.0, dp = 1.0;

	gpu::HoughCircles(pS.gpuGrayImage, pS.gpuCircles, pS.gpuBuf,
			CV_HOUGH_GRADIENT, dp, minDist, cannyThresh, voteThresh, minRadius,
			maxRadius, maxCircles);

	gpu::HoughCirclesDownload(pS.gpuCircles, circles);
}
